/**  
* @Title: CityRunUtils.java
* @Package com.lemon.utils
* @Description: (一句话阐述):
* @author Ran_cc
* @date 2018年11月12日
* @version V1.0  
*/
package com.lemon.utils;

import java.util.Date;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.lemon.utils.sval.StaticValues;

/**
 * <p>Title: CityRunUtils</p>
 * <p>Description: 
 * </p>
 * <p>Company: </p>
 * @author Ran_cc
 * @date 2018年11月12日
 * @版本 V 1.0 
 */
public class CityRunUtils {


	/**
	 * <b>Description:<blockquote> 获取营业起止时间
	 * </blockquote></b>
	 * 
	 * @Title: getBusineDate
	 * @return
	 * @author Ran_cc
	 * @date 2018年11月12日
	 */
	public static Date getBusineDate() {
		Date date = StringUtil.StringToDate(StaticValues.TODAY_TIME() , 4);
		Date date2 = new Date();
		if (date.getTime() > date2.getTime()) {
			return StringUtil.StringToDate(StaticValues.YESTERDAY_TIME() , 4);
		} else {
			return StringUtil.StringToDate(StaticValues.TODAY_TIME() , 4);
		}
	}

	public static String getBusineDateString() {
		Date date = StringUtil.StringToDate(StaticValues.TODAY_TIME() , 4);
		Date date2 = new Date();
		if (date.getTime() > date2.getTime()) {
			return StaticValues.YESTERDAY_TIME();
		} else {
			return StaticValues.TODAY_TIME();
		}
	}

	public static void setOrderTimesCookie(String shopId) {
		ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder
				.getRequestAttributes();
		//		HttpServletRequest request = (HttpServletRequest) requestAttributes.getRequest();
		HttpServletResponse response = requestAttributes.getResponse();

		Cookie cookie3 = new Cookie("_p_t_" + shopId, new Date().getTime() + "");
		cookie3.setPath("/");
		response.addCookie(cookie3);
	}
}
